<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var s = document.URL;

    var firstIndex = s.indexOf("?");
    var allParams = s.substring(firstIndex+1);
    var paramArray = allParams.split("&");
    var out_trade_no;

    for(var i=0;i<paramArray.length;i++){
        if(paramArray[i].indexOf("out_trade_no")!=-1){
            var equalIndex = paramArray[i].indexOf("=");
            out_trade_no = paramArray[i].substring(equalIndex+1);
            break;
        }
    }

    alert(out_trade_no);

    if(s.indexOf("total_amout")!=-1){
       // document.write("支付成功");
       // alert(localStorage[0]);
       // alert(localStorage[1]);
        var waitPayOrderList =
            JSON.parse(localStorage.getItem("waitPayOrderList"));
        //alert(waitPayOrderList.length);

        console.log(waitPayOrderList);

        var waitFaHuoOrderList =
            JSON.parse(localStorage.getItem("waitFaHuoOrderList"));

        if(!waitFaHuoOrderList){
            waitFaHuoOrderList = [];
        }

        //alert(waitPayOrderList.length);
        if(!waitPayOrderList) {
            // 向服务器拉数据
        }else{

            for(var i=0;i<waitPayOrderList.length;i++){
                var o = waitPayOrderList[i];

                if(o.myorderno==out_trade_no){
                    waitFaHuoOrderList.push(o);
                    waitPayOrderList.splice(i,1);
                    break;
                }
            }
        }

        localStorage.setItem("waitPayOrderList",
            JSON.stringify(waitPayOrderList));
        localStorage.setItem("waitFaHuoOrderList",
            JSON.stringify(waitFaHuoOrderList));
    }
</script>

<div>您可能还喜欢</div>
</body>
</html>